﻿//--------------------------------------------------------------------------
// 
//  Copyright (c) Chili Software.  All rights reserved. 
// 
//  File: ConcurrencyManagerEventArgs.cs
//
//  Description: Class used as argument of the IConcurrencyManager methods.
// 
//--------------------------------------------------------------------------

using System;

namespace Chili.Opf3.Concurrency
{
	/// <summary>
	/// EventArgs of the <see cref="Opf3.Concurrency.IConcurrencyManager">IConcurencyManager</see> methods. 
	/// This class is passed as second parameter of each 
	/// <see cref="Opf3.Concurrency.IConcurrencyManager">IConcurencyManager</see> method.
	/// </summary>
	[Serializable]
	public sealed class ConcurrencyManagerEventArgs : EventArgs
	{
		private ObjectInfo _objectInfo;
		private ObjectContext _context;

		/// <summary>
		/// Creates a new instance of the <see cref="ConcurrencyManagerEventArgs">ConcurrencyManagerEventArgs Class</see>.
		/// </summary>
		/// <param name="objectInfo"><see cref="Opf3.ObjectInfo">ObjectInfo</see> container that contains 
		/// persistent informations about the persistent object.</param>
		/// <param name="context"><see cref="Opf3.ObjectContext">ObjectContext</see> that asked for validation.</param>
		internal ConcurrencyManagerEventArgs(ObjectInfo objectInfo, ObjectContext context)
		{
			if (objectInfo == null)
				throw new ArgumentNullException("objectInfo");
			if (context == null)
				throw new ArgumentNullException("context");

			_objectInfo = objectInfo;
			_context = context;
		}

		/// <summary>
		/// Returns the <see cref="Opf3.ObjectInfo">ObjectInfo</see> container that contains 
		/// persistent informations about the object.
		/// </summary>
		public ObjectInfo ObjectInfo
		{
			get { return _objectInfo; }
		}

		/// <summary>
		/// Returns the <see cref="Opf3.ObjectContext">ObjectContext</see> that asked for validation.
		/// </summary>
		public ObjectContext Context
		{
			get { return _context; }
		}
	}
}
